package com.some;

import java.util.HashMap;
import java.util.Scanner;

public class Didi_01 {

    public int mostTime(int K, int R) {
        int sum = 0;
        HashMap<Integer, Integer> map = new HashMap<>();
        int max = Integer.MIN_VALUE;
        for (int i = 1; i <= R; i++) {
            if (i < K) {
                map.put(i,0);
            }
            int times = getTimes(i, K);
            map.put(i, times);
            max = Math.max(max, times);
        }
        for (int num : map.keySet()) {
            if (map.get(num) == max) {
                sum++;
            }
        }
        return sum;
    }

    public int getTimes(int num, int K) {
        int time = 0;
        while (num / K > 0 && num % K == 0) {
            num /= K;
            time++;
        }
        return time;
    }

    public static void main(String[] args) {
        Didi_01 didi_01 = new Didi_01();
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int R = sc.nextInt();
        System.out.println(didi_01.mostTime(K, R));
    }
}
